//
//  FSMessageViewController.m
//  fanshu
//
//  Created by 刘开 on 16/4/5.
//  Copyright © 2016年 FS. All rights reserved.
//

#import "FSMessageViewController.h"
#import "FSGroup.h"
#import "FSRow.h"


#import "FSArrow.h"
#import "FSSettingCell.h"
#import "FSTalkViewController.h"

@interface FSMessageViewController ()
@property (nonatomic,strong)NSMutableArray *groupArray;


@end

@implementation FSMessageViewController

- (NSMutableArray *)groupArray{
    if (!_groupArray) {
        _groupArray = [NSMutableArray array];
    }
    return _groupArray;
}

//初始化组样式
-(instancetype)init {
    return [super initWithStyle:UITableViewStyleGrouped];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
//    设置标头
    self.title=@"消息";
    
//    添加一组
    [self addgrop];
//  设置右侧图片
    self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"icon_notification_settings"] style:0 target:self action:nil];
    
}

-(void)addgrop{
//    描述模型
    
    FSArrow *item1=[FSArrow settingRowItemWithTitle:@"评论" image:[UIImage imageNamed:@"icon_tabbar_comment"]];
    //需要跳转的类
//    item1.desClass=[FSTalkViewController class];
   
    
    
  FSArrow *item2=[FSArrow settingRowItemWithTitle:@"简信" image:[UIImage imageNamed:@"icon_notification_message"]];
    FSRow *item3=[FSRow settingRowItemWithTitle:@"请求" image:[UIImage imageNamed:@"icon_notification_request"]];
     FSRow *item4=[FSRow settingRowItemWithTitle:@"喜欢" image:[UIImage imageNamed:@"icon_notification_like"]];
    FSRow *item5=[FSRow settingRowItemWithTitle:@"关注" image:[UIImage imageNamed:@"icon_notification_follow"]];
     FSRow *item6=[FSRow settingRowItemWithTitle:@"其他提醒" image:[UIImage imageNamed:@"icon_notification_more"]];
    
    
    //    一组有多少行
    NSArray *rowArray=@[item1,item2,item3,item4,item5,item6];
    
//    创建一个组模型
    
//    FSGroup *groupitem=[FSGroup settingItemWithRowArray:rowArray];
    FSGroup *groupitem = [[FSGroup alloc] init];
    groupitem.rowArray = rowArray;
    
    [self.groupArray addObject:groupitem];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
//    return 10;
    FSGroup *group = self.groupArray[section];
    return group.rowArray.count;
//    return 2
//    return arr.count;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return self.groupArray.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//    创建cell
    FSSettingCell *cell=[FSSettingCell cellwithWithTableView:tableView];
    FSGroup *group = self.groupArray[indexPath.section];
    FSRow *row = group.rowArray[indexPath.row];
    cell.rowItem = row;
    
    return cell;
}

@end
